package com.aeye.mbr.ws.util;

import com.aeye.mbr.common.util.RedisUtil;

import java.util.UUID;

/**
 * 上传图片到redis服务器中
 */
public class RedisImgUtils {
    private final static int UPMS_IMG_TIME = 60*1;
    public final static String UPMS_IMG_ID_PREFIX = "AEPIC#";
    //上传图片后返回一个唯一编码给终端
    public static String putImage(byte[] data){
        String uuid = UPMS_IMG_ID_PREFIX+UUID.randomUUID().toString().replaceAll("_","").toUpperCase();
        try {
            RedisUtil.set(uuid.getBytes(),data,UPMS_IMG_TIME);
            return uuid;
        }catch (Exception e){
            return null;
        }
    }

    //获取图片的编号
    public static byte[] getRedisImg(String uuid){
        return RedisUtil.get(uuid.getBytes());
    }
}
